<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/26 0026
 * Time: 上午 11:37
 */
namespace App\Api\Service\Branch\Controllers;

use Framework\BaseClass\Api\Controller;
use App\Eloquent\Ygt\Plate;
use App\Eloquent\Ygt\Branch;
use App\Engine\Func;
use App\Eloquent\Ygt\DepartmentUser;

class IndexController extends Controller
{
    public function branchDel()
    {
        $userId = Func::getHeaderValueByName('userid');
        $userInfo = DepartmentUser::getCurrentInfo($userId);
        $companyId = isset($userInfo['company_id']) ? $userInfo['company_id'] : '';

        $branchId = request('id');
        $where = [
            'id'=>$branchId,
            'company_id'=>$companyId,
        ];
        $branchModel = new Branch();
        if($re = $branchModel->del($where)){
            return 'ok';
        }else{
            xThrow(ERR_BRANCH_DELETE_FAIL);
        }

    }
}